package com.nulstudio.sppm.network;

import java.util.Objects;

public final class Result<T> {

    private final int code;

    private final String message;

    private final T result;

    public Result() {
        this.code = 0;
        this.message = "";
        this.result = null;
    }

    public Result(T result) {
        this.code = 0;
        this.message = "";
        this.result = result;
    }

    public Result(int code, String message) {
        this.code = code;
        this.message = message;
        this.result = null;
    }

    public int getCode() {
        return code;
    }

    public String getMessage() {
        return message;
    }

    public T getResult() {
        return result;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Result<?> result1 = (Result<?>) o;
        return code == result1.code && Objects.equals(message, result1.message) && Objects.equals(result, result1.result);
    }

    @Override
    public int hashCode() {
        return Objects.hash(code, message, result);
    }
}
